<?

if ($c = stack('name')) {
	
	$_id_data		= D_MB_DATA;			//	meta id value
	$_id_meta		= D_MB_META;			//	meta id value

	$s = component_settings($c);

	if ($_id_component = (int)$s['catalogs']) {
		
		$_crit = "id_data=$_id_data AND id_parent=$_id_component AND attr & ".AA_VISIBLE;
//dbdebug();		
		$DATA['components'][$c]['data'] = datafetch_array('db_list', array(
			'table' => tb('data'), 
			'where' => $_crit,	
			'order' => 'id_index '.($s['order'] ? 'DESC' : 'ASC'), 
			'limit' => (int)$s['num'],
			'index' => 'id' ));

		foreach($DATA['components'][$c]['data'] as $id => $v) {
			$DATA['components'][$c]['data'][$id] = array_merge($v, datafetch_array('meta', $_id_meta, $id, $CONTEXT['lang']));
			$DATA['components'][$c]['data'][$id]['date'] = format_simple_date($v['date_create']);
		}

//debug($DATA['components'][$c]['data']);			

	}
	
	unstack();
}

?>